package com.xx.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class WebConfiguration implements WebMvcConfigurer {

	/**
	 * 忽略的URL
	 */
	private static List<String> EXCLUDELIST = new ArrayList<>();
	static {
		EXCLUDELIST.add("/login");
		//放行swagger文档
		EXCLUDELIST.add("/doc.html");
		EXCLUDELIST.add("/swagger**/**");
		EXCLUDELIST.add("/swagger-resources/**");
		EXCLUDELIST.add("/webjars/**");
		EXCLUDELIST.add("/v3/**");
		EXCLUDELIST.add("/login.do");
		EXCLUDELIST.add("/logout.do");
		EXCLUDELIST.add("/resource/**");
	}

	/**
	 * 配置拦截器
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**").excludePathPatterns(EXCLUDELIST);
	}
}